/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cs425proj.model;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;

/**
 *
 * @author prateekpatil
 */
public class theaterDetail {
    
    private int theater_id;
    private int numofscreens;
    private long phone;
    private String theater_name;
    private String address;
    private String  city;
    private String state;
    private int zipcode;
    
    public ArrayList<String> getCityList()
    {
        ArrayList <String> cityList = new ArrayList<String>();
         ResultSet rs;
        try{
        connectDB obj = new connectDB();
        
        Statement stm;
        stm =  obj.startConnection().createStatement();
        //Querries
        rs = stm.executeQuery("select distinct(city) from theater");
        while(rs.next()){
            
//            this.setTheater_id(rs.getInt(1));
//            this.setNumofscreens(rs.getInt(2));
//            this.setPhone(rs.getLong(3));
//            this.setTheater_name(rs.getString(4));
//            this.setAddress(rs.getString(5));
//            this.setCity(rs.getString(6));
//            this.setState(rs.getString(7));
//            this.setZipcode(rs.getInt(8));
              
            cityList.add(rs.getString(1));
        }    
        obj.closeConnection();
        }catch(SQLException e){e.printStackTrace();}
    return cityList;
    }
    
    public ArrayList<String> getTheaterList(String movie)
    {
        ArrayList <String> theaterList = new ArrayList<String>();
         ResultSet rs;
        try{
        connectDB obj = new connectDB();
        
        
        Statement stm;
        stm =  obj.startConnection().createStatement();
        //Querries
        rs = stm.executeQuery("select theater_name from theater where theater_id in (select distinct(theater_id) from screen where screen_id in (select screen_id from schedule where movie_id in (select movie_id from movie where name='"+movie+"')))");
        while(rs.next()){
            theaterList.add(rs.getString(1));
        }
    obj.closeConnection();
    }catch(SQLException e){e.printStackTrace();}
    return theaterList;
    }    
    
    public ArrayList<String> getTheaterList()
    {
        ArrayList <String> theaterList = new ArrayList<String>();
         ResultSet rs;
        try{
        connectDB obj = new connectDB();
        
        
        Statement stm;
        stm =  obj.startConnection().createStatement();
        //Querries
        rs = stm.executeQuery("select * from theater ");
        while(rs.next()){
            theaterList.add(rs.getInt(1)+" "+rs.getString(4));
        }
    obj.closeConnection();
    }catch(SQLException e){e.printStackTrace();}
    return theaterList;
    }    

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public int getNumofscreens() {
        return numofscreens;
    }

    public void setNumofscreens(int numofscreens) {
        this.numofscreens = numofscreens;
    }

    public long getPhone() {
        return phone;
    }

    public void setPhone(long phone) {
        this.phone = phone;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public int getTheater_id() {
        return theater_id;
    }

    public void setTheater_id(int theater_id) {
        this.theater_id = theater_id;
    }

    public String getTheater_name() {
        return theater_name;
    }

    public void setTheater_name(String theater_name) {
        this.theater_name = theater_name;
    }

    public int getZipcode() {
        return zipcode;
    }

    public void setZipcode(int zipcode) {
        this.zipcode = zipcode;
    }
    
    

    
}
